package properties;

import java.util.Properties;
import java.util.Set;

/**
 * Created by 5406160@qq.com on LiBoWen 李博闻.
 *
 * @ClassName : PropertiesDemo
 * @Author : 54061
 * @Date: 2022/2/15 15:06
 */
/*
推荐使用的方法
    put的替换方法 : Object setProperty(String Key,String value)
    get的替换方法 :
                    String getProperty(String Key)
                    String getproperty(String Key, String defaultvalue)
    KeySet的替换方法
                   Set<String> stringProperyNaems()
 */
public class PropertiesDemo {
    public static void main(String[] args) {
        //创建集合
        Properties properties = new Properties();
        //增
        properties.setProperty("version","1.0");
        properties.setProperty("author","Damon");
        properties.setProperty("Date","2021/12/25");

        System.out.println("properties = " + properties);
        //遍历集合
        Set<String> keys = properties.stringPropertyNames();
        for (String key : keys) {
            //根据键找值
            String value = properties.getProperty(key, "没有找到对于键~");
            System.out.println(key +" -- "+ value);
        }
    }
}
